package maopoa;

public class test1 {
    public static void main(String[] args) {
        getMax();
    }
    public static void getMax(){
        int[] arr = {2,3,5,1,4};
        int flag = arr.length;
        int ff = 0;
        while (flag >= 0){
            for (int i = 0; i < flag-1; i++) {
                if(arr[i] > arr[i+1]){
                    int cache = arr[i];
                    arr[i] = arr[i+1];
                    arr[i+1] = cache;
                }
                ff++;
            }
            flag-=1;

        }

        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
        System.out.println(ff);
    }
}
